﻿using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
namespace WPFExcelReport
{
    public partial class TFSTKCHG
    {
        public TFSTKCHG()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VICC_STOCKCHG();
            this.DataContext = MV;
            InitializeComponent();

        }
        public override void LOADBYAUF()
        {
            try
            {
                TBMain.Clear();
                if (ORDERNUM.Length < 152)
                    return;
                dwData = TBMain.NewRow();
                dwData["MANDANT"] = app.Mandant;
                dwData["LO"] = ORDERNUM.Substring(0, 2);
                dwData["LB"] = ORDERNUM.Substring(2, 2);
                if (IsRange)
                {
                    dwData["BSDES"] = "AND MDATE>=" + DTSTART + " AND MDATE<=" + DTEND;
                }
                else
                {
                    dwData["BSDES"] = "AND MDATE=" + ORDERNUM.Substring(4, 8);
                }
                dwData["WAKZ"] = ORDERNUM.Substring(12, 1);
                dwData["ART"] = ORDERNUM.Substring(13, 20);
                dwData["VAR"] = ORDERNUM.Substring(33, 2);
                dwData["FARBE"] = ORDERNUM.Substring(35, 10);
                dwData["FINISH"] = ORDERNUM.Substring(45, 10);
                dwData["DESS"] = ORDERNUM.Substring(55, 10);
                dwData["COLORIT"] = ORDERNUM.Substring(65, 10);
                dwData["FSIZE"] = ORDERNUM.Substring(75, 7);
                dwData["FBPART"] = ORDERNUM.Substring(82, 10);
                dwData["SPPART"] = ORDERNUM.Substring(92, 10);
                dwData["ZWPART"] = ORDERNUM.Substring(102, 10);
                dwData["BEM1"] = ORDERNUM.Substring(112, 40);
                SResult = TMV.QSTKCHG03(dwData);
                MergeData(SResult, true);
                base.LOADBYAUF();
            }
            catch(Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            
        }
    }
}
